package com.chen.proxyReviw;

import com.chen.proxyReviw.dto.User;
import com.chen.proxyReviw.dto.impl.UserServiceImpl;
import com.chen.proxyReviw.server.UserService;
import com.chen.proxyReviw.util.ProxyUtils;

import java.util.List;

public class ProxyRev {
    public static void main(String[] args) {
        // 复习动力技术
        // 使用动态代理，在不改变业务代码的清空先，为每个方法统计耗时
        UserServiceImpl service = new UserServiceImpl();
        User user1 = new User(7, "chenT", "hrjdbbf", 24);
        User user2 = new User(9, "ya", "hrbbf", 29);
        // 创建代理类
        UserService proxy = ProxyUtils.createProxyInstance(service);
        List<User> all = proxy.findAll();
        System.out.println(all.size());
        proxy.findById(1);
        proxy.update(user1);
        proxy.save(user2);
        proxy.delete(2);
    }
}
